package com.zhuiyun.project.api.plan.fitnessPurpose.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zhuiyun.project.annotation.OptLog;
import com.zhuiyun.project.api.plan.fitnessPurpose.mapper.FitnessPurposeMapper;
import com.zhuiyun.project.api.plan.fitnessPurpose.service.FitnessPurposeService;
import com.zhuiyun.project.api.plan.fitnessPurpose.entity.FitnessPurpose;
import com.zhuiyun.project.common.errorCode.CommonException;
import com.zhuiyun.project.common.response.CommonResult;
import com.zhuiyun.project.utils.constants.CommonConstants;
import com.zhuiyun.project.utils.pageUtil.PageRequest;
import com.zhuiyun.project.utils.pageUtil.PageResult;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @ClassName FitnessActionController
 * @Description TODO
 * @Author ys
 * @Date 2023/11/2 8:48
 **/
@RestController
@RequestMapping("/plan")
public class FitnessPurposeController {
    @Autowired
    private FitnessPurposeService fitnessPurposeService;

    @Resource
    FitnessPurposeMapper fitnessPurposeMapper;
    /**
    * @Author 杨珅
    * @Description todo 健身目的查询
    * @Date 2023/11/2 9:28
    * @Return  * @param null
    */
//    @PreAuthorize("@ss.hasPermi('plan:fitnessPurpose')")
//    @ApiOperation(value = "健身目的查询")
//    @OptLog(modular = "健身目的列表", type = CommonConstants.SELECT, describe = "健身目的查询 ")
//    @GetMapping("/getFitnessPurpose")
//    public CommonResult selectAll(PageRequest pageRequest, String fitnessPurposeName,String venueUniqueIdentifier){
//        PageResult pageResult = fitnessPurposeService.selectAll(pageRequest,fitnessPurposeName,venueUniqueIdentifier);
//        return CommonResult.ok(pageResult);
//    }

    /**
    * @Author 摸鱼飞弹
    * @Description TODO 健身目的查询
    * @Date 2024/3/4 15:00
    * @Return
    * @param null
    */
    @PreAuthorize("@ss.hasPermi('plan:fitnessPurpose')")
    @ApiOperation(value = "健身目的查询")
    @OptLog(modular = "健身目的列表", type = CommonConstants.SELECT, describe = "健身目的查询 ")
    @GetMapping("/getFitnessPurpose")
    public CommonResult selectAll(String fitnessPurposeName,String venueUniqueIdentifier){
        return CommonResult.ok(fitnessPurposeService.selectAll(fitnessPurposeName,venueUniqueIdentifier));
    }

    /**
     * @Author 杨珅
     * @Description todo 健身目的查询
     * @Date 2023/11/2 9:28
     * @Return  * @param null
     */
    @PreAuthorize("@ss.hasPermi('plan:fitnessPurpose')")
    @ApiOperation(value = "健身目的查询")
    @OptLog(modular = "健身目的列表", type = CommonConstants.SELECT, describe = "健身目的查询 ")
    @GetMapping("/queryFitnessPurpose")
    public CommonResult queryAll(String venueUniqueIdentifier){
        return CommonResult.ok(fitnessPurposeService.queryAll(venueUniqueIdentifier));
    }
    /**
     * @Author 杨珅
     * @Description todo 健身目的新增
     * @Date 2023/11/2 9:28
     * @Return  * @param null
     */
    @PreAuthorize("@ss.hasPermi('plan:fitnessPurpose')")
    @ApiOperation(value = "健身目的新增")
    @OptLog(modular = "健身目的列表", type = CommonConstants.ADD, describe = "健身目的新增 ")
    @PostMapping("/addFitnessPurpose")
    public CommonResult insertFitnessPurpose(@RequestBody FitnessPurpose fitnessPurpose)throws CommonException {
        return CommonResult.ok(fitnessPurposeService.insertFitnessPurpose(fitnessPurpose));
    }
    /**
     * @Author 杨珅
     * @Description todo 健身目的新增
     * @Date 2023/11/2 9:28
     * @Return  * @param null
     */
    @PreAuthorize("@ss.hasPermi('plan:fitnessPurpose')")
    @ApiOperation(value = "健身目的修改")
    @OptLog(modular = "健身目的列表", type = CommonConstants.UPDATE, describe = "健身目的修改 ")
    @PutMapping("/updateFitnessPurpose")
    public CommonResult updateFitnessPurpose(@RequestBody FitnessPurpose fitnessPurpose)throws  CommonException{
        return CommonResult.ok(fitnessPurposeService.updateFitnessPurpose(fitnessPurpose));
    }
    /**
     * @Author 杨珅
     * @Description todo 健身目的删除
     * @Date 2023/11/2 9:28
     * @Return  * @param null
     */
    @PreAuthorize("@ss.hasPermi('plan:fitnessPurpose')")
    @ApiOperation(value = "健身目的删除")
    @OptLog(modular = "健身目的列表", type = CommonConstants.DELETE, describe = "健身目的删除 ")
    @DeleteMapping("/deleteFitnessPurpose")
    public CommonResult deleteFitnessPurpose(@RequestBody FitnessPurpose fitnessPurpose){
        return CommonResult.ok(fitnessPurposeService.deleteFitnessPurpose(fitnessPurpose));
    }

    /*
    * @Author xy
    * @Description todo 课程类型下拉菜单
    * @Date 2023/11/29 10:00
    * @Return
    * @param
    */
    @GetMapping("/selectCourseType")
    @ApiOperation(value = "课程类型下拉菜单")
    @OptLog(modular = "健身目的列表",type = CommonConstants.SELECT,describe = "课程类型下拉菜单")
    public CommonResult selectCourseType(){
        QueryWrapper<FitnessPurpose> queryWrapper = new QueryWrapper<>();
        List<FitnessPurpose> fitnessPurposes = fitnessPurposeMapper.selectList(queryWrapper);
        return CommonResult.ok(fitnessPurposes);
    }
}
